// JavaScript Document

var get_image = {	
	src : '',
	path : '',
	width : '',
	height : '',
	vspace : '',
	hspace : '',
	border : '',
	align : 'left',
	alt : '',
	browse_server : function() 
	{
		// validate
		var width = 500;
		var height = 400;
		var iLeft = 200;
		var iTop = 200;
		var sOptions = "toolbar=no,status=no,resizable=yes,dependent=yes,scrollbars=yes" ;
		sOptions += ",width=" + width ;
		sOptions += ",height=" + height ;
		sOptions += ",left=" + iLeft ;
		sOptions += ",top=" + iTop ;
		window.open(SITE_URL + 'admin_ajax/upload_images.upload_images.lists/','Upload_Image',sOptions);
		return true;
    },
	
	change_property : function(pro,value)
	{
		var image_pre = window.document.getElementById('image_pre');	
		
		if(pro=="width"){
			this.width = parseInt(value);	
			image_pre.width = parseInt(value);
		}
		else if(pro=="height"){
			this.height = parseInt(value);
			image_pre.height = parseInt(value);	
		}
		else if(pro=="vspace"){
			this.vspace = parseInt(value);
			image_pre.vspace = parseInt(value);	
		}
		else if(pro=="hspace"){
			this.hspace = parseInt(value);
			image_pre.hspace = parseInt(value);	
		}
		else if(pro=="border"){
			this.border = parseInt(value);
			image_pre.border = parseInt(value);		
		}
		else if(pro=="align"){
			this.align = value;
			image_pre.align = value;		
		}
		else if(pro=="alt"){
			this.alt = value;
			image_pre.alt = value;		
		}
	},
	
	ok_Click : function (value)
	{
		var image_pre = window.document.getElementById('image_pre');
		this.src = image_pre.src; 				
		var arr_src = new Array();
		arr_src = this.src.split("/");
		if(arr_src.length>0){
			this.src = arr_src[arr_src.length-1]; 		
			var url = document.getElementById('url');
			//this.path = url.value;
			this.path = arr_src[arr_src.length-1];
		}
		else{
			this.path = "";
		}
		this.onClicked(this);		
		/*
			
			var out0 = window.document.getElementById('out0');
			out0.src = image_pre.src;		
		*/
		iBox.hide();
		
	},
	toImage : function(id){
		obj = document.getElementById(id);
		if(this.src)
			obj.src = IMAGE_FRANCHISE_PATH+'/'+this.path;
		if(this.width)	
			obj.width = this.width;
		if(this.height)
			obj.height = this.height;
		if(this.vspace)
			obj.vspace = this.vspace;
		if(this.hspace)
			obj.hspace = this.hspace;
		if(this.border)
			obj.border = this.border;
		if(this.align)
			obj.align = this.align;
		if(this.alt)
			obj.alt = this.alt;	
	},
	toImageFromObject : function(id, fromobj){
		obj = document.getElementById(id);
		if(fromobj.src){			
			obj.src = IMAGE_FRANCHISE_PATH+'/'+fromobj.path;			
		}		
		if(fromobj.width)	
			obj.width = fromobj.width;
		if(fromobj.height)
			obj.height = fromobj.height;
		if(fromobj.vspace)
			obj.vspace = fromobj.vspace;
		if(fromobj.hspace)
			obj.hspace = fromobj.hspace;
		if(fromobj.border)
			obj.border = fromobj.border;
		if(fromobj.align)
			obj.align = fromobj.align;
		if(fromobj.alt)
			obj.alt = fromobj.alt;	
	}
}
